<template>
  <div id="bottomLeft">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span style="color:#5cd9e8">
          <icon name="chart-bar"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-xl text mx-2">当日疫情数据统计图</span>
        </div>
      </div>
      <div>
        <BottomLeftChart :cdata="cdata"/>
      </div>
    </div>
  </div>
</template>

<script>
import BottomLeftChart from "@/components/echart/bottom/bottomLeftChart";
export default {
  data() {
    return {
      cdata:{}
    };
  },
  components: {
    BottomLeftChart
  },
  mounted() {
    this.getdata();
  },
  methods: {
    async getdata(){
      let self = this;
      this.$http.get('http://116.196.92.193:8090/data/getBottomLeft', {
        params: {
        }
      }).then(function (response) {
        //console.info(response);
        var deathmap = response.data.data.deathmap;
        var casemap = response.data.data.casemap;
        var category = [];
        var lineData = [];
        var barData = [];
        var rateData = [];
        for(var k1 in casemap){
          category.push(k1);
          lineData.push(casemap[k1]);
        }
        for(var k2 in deathmap){
          barData.push(deathmap[k2]);
        }
        for (let i = 0; i < barData.length -1; i++) {
          let rate = barData[i] / lineData[i];
          rateData.push(rate.toFixed(2));
        }

        self.cdata = {
          category:category,
          lineData:lineData,
          barData:barData,
          rateData: rateData
        }



      }).catch(function (error) {
        console.log(error);
      });
    },
  }
};
</script>

<style lang="scss">
#bottomLeft {
  padding: 0.3rem 0.2rem;
  height: 6.5rem;
  min-width: 3.75rem;
  border-radius: 0.0625rem;
  .bg-color-black {
    height: 6.0625rem;
    border-radius: 0.125rem;
  }
  .text {
    color: #c3cbde;
  }
  .chart-box {
    margin-top: 0.2rem;
    width: 2.125rem;
    height: 2.125rem;
    .active-ring-name {
      padding-top: 0.125rem;
    }
  }
}
</style>
